
 /**
 * User.java.java.
 * User: BrianChen Date: 2012-6-5 下午03:37:38
 *
 * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
 * All rights reserved.
 */
package com.collapsar.core.security.model;

import java.util.HashSet;
import java.util.Set;

import com.collapsar.core.orm.model.VersionalEntity;

/**
 * <pre>
 * REVISIONS: 
 * Version 	Date 		Author 			Description
 * ------------------------------------------------------------------- 
 * 1.0 		2012-6-5 	BrianChen 	1. Created this class. 
 * </pre>
 * 
 * @author BrianChen
 * @date 2012-6-5 下午03:37:38
 * @version 1.0
 * @see
 * 
 */
@SuppressWarnings("serial")
public class User extends VersionalEntity{
	private String account = null;
	private String passwd = null;
	private String email = null;
	private boolean enable = true;
	private UserInfo userInfo = null;
	//private Set<Role> roles = new HashSet<Role>();
	private Set<Group> groups = new HashSet<Group>();
	
	
	
	
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public String getPasswd() {
		return passwd;
	}
	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public boolean isEnable() {
		return enable;
	}
	public void setEnable(boolean enable) {
		this.enable = enable;
	}
	public UserInfo getUserInfo() {
		return userInfo;
	}
	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}
//	public Set<Role> getRoles() {
//		return roles;
//	}
//	public void setRoles(Set<Role> roles) {
//		this.roles = roles;
//	}
	public Set<Group> getGroups() {
		return groups;
	}
	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}
	@Override
	public int hashCode() {
		return this.account.hashCode();
	}
	@Override
	public boolean equals(Object obj) {
		if(this == obj){
			return true;
		}
		if(!(obj instanceof User)){
			return false;
		}
		final User user = (User)obj;
		if(!this.account.equals(user.getAccount())){
			return false;
		}
		return true;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("{account=");
		sb.append(this.account);
		sb.append(", passwd=");
		sb.append(this.passwd);
		sb.append(", email=");
		sb.append(this.email);
		sb.append("}");
		
		return sb.toString();
	}
	
}

